package com.xsqf.jt808.common.vo.req.server;

import com.xsqf.jt808.common.config.ParameterId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

/**
 * TerminalParameter
 *
 * @author
 * @date 2020/5/26 15:26
 */
@Data
//@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "终端参数项")
public class TerminalParameter {

    @ApiModelProperty(value = "参数ID")
    private Integer id;

    /**
     * 熄火上传间隔 0x0027 ，点火上传间隔 0x0022 ，拐点补传角度 0x0030 ，心跳上传间隔 0x0001
     */
    @ApiModelProperty(value = "参数ID")
    private ParameterId idType;

    @ApiModelProperty(value = "参数长度")
    private Integer length;

    @ApiModelProperty(value = "参数值")
    private Integer bytesValue;

    public TerminalParameter(Integer id) {
        this.id = id;
        this.idType= ParameterId.toEnum(id);
    }

//    @Property(index = 0, type = DataType.DWORD, desc = "参数ID")
//    public Integer getId() {
//        return id;
//    }

    public void setId(Integer id) {
        this.id = id;
        this.idType = ParameterId.toEnum(id);
    }

//    public ParameterId getIdType() {
//        return idType;
//    }

    public void setIdType(ParameterId idType) {
        this.idType = idType;
        this.id = idType.value;
    }

//    @Property(index = 1, type = DataType.BYTE, desc = "参数长度")
//    public Integer getLength() {
//        return length;
//    }
//
//    public void setLength(Integer length) {
//        this.length = length;
//    }
//
//    @Property(index = 2, type = DataType.BYTES, lengthName = "length", desc = "参数值")
//    public byte[] getBytesValue() {
//        return bytesValue;
//    }
//
//    public void setBytesValue(byte[] bytesValue) {
//        this.bytesValue = bytesValue;
//    }

    @Override
    public String toString() {
        return ReflectionToStringBuilder.toString(this, ToStringStyle.SHORT_PREFIX_STYLE);
    }
}
